//
//  MBDNavigationController.swift
//  MasterBoy
//
//  Created by kyson on 2023/3/17.
//

import Foundation
import UIKit

class MBDNavigationController: UINavigationController {
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
    
    override init(rootViewController: UIViewController) {
        super.init(rootViewController: rootViewController)
        
        /************************************************************以下代码和主题、状态栏颜色相关********************************************************************************/
          
  
  //        //强制状态栏黑色
          //如果 barStyle 是 .black ，那么系统栏就是 .lightContent 也就是白色；但如果 barStyle 是 .default ，那么系统栏就也是默认的黑色了。
        
//        if #available(iOS 13, *) {
//            UISearchBar.appearance(whenContainedInInstancesOf: [UINavigationItem.self]).backgroundColor = .white
//        }
        UISearchBar.appearance().searchTextPositionAdjustment = UIOffset(horizontal: 3, vertical: 0)
        self.navigationBar.setDynamicNavigationBarBackgroundColor2()


    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        let viewControllers = self.viewControllers
        if(viewControllers.count > 0) {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: true)
    }
    
//    override var childForStatusBarStyle: UIViewController? {
//        return self.topViewController
//    }
//    
////    childViewControllerForStatusBarStyle
//    override var preferredStatusBarStyle: UIStatusBarStyle {
//        return self.topViewController!.preferredStatusBarStyle
//    }
//    
//    override var prefersStatusBarHidden: Bool {
//        return self.topViewController!.prefersStatusBarHidden
//    }
}
